package day8;

class Human{
    public void showName(){
        System.out.println("I am Human");
    }
}

class Doctor extends Human{
    public void showName(){
        System.out.println("I am Doctor");
    }
}

class Porgrammer extends Human{
    public void showName(){
        System.out.println("I am Porgrammer");
    }
}

public class Test {
    public Human humanFactory(String humanType){
        if ("doctor".equals(humanType)){
            return new Doctor();
        }
        else if ("programmer".equals(humanType)){
            return new Porgrammer();
        }
        else {
            return new Human();
        }
    }

    public static void main(String[] args) {
        Test test = new Test();
        Human human = test.humanFactory("doctor");
        human.showName();
        human = test.humanFactory("programmer");
        human.showName();
    }

}
